home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / alien-glow-arrow.scm < prev    next >
Encoding:
Text File  |  2009-08-19  |  5.5 KB  |  189 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Alien Glow themed arrows for web pages
  5. ; Copyright (c) 1997 Adrian Likins
  6. ; aklikins@eos.ncsu.edu
  7. ;
  8. ;
  9. ; Based on code from
  10. ; Federico Mena Quintero
  11. ; federico@nuclecu.unam.mx
  12. ;
  13. ; This program is free software: you can redistribute it and/or modify
  14. ; it under the terms of the GNU General Public License as published by
  15. ; the Free Software Foundation; either version 3 of the License, or
  16. ; (at your option) any later version.
  17. ;
  18. ; This program is distributed in the hope that it will be useful,
  19. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ; GNU General Public License for more details.
  22. ;
  23. ; You should have received a copy of the GNU General Public License
  24. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25.  
  26. (define (script-fu-alien-glow-right-arrow size
  27.                                           orientation
  28.                                           glow-color
  29.                                           bg-color
  30.                                           flatten)
  31.  
  32.   ; some local helper functions, better to not define globally,
  33.   ; since otherwise the definitions could be clobbered by other scripts.
  34.   (define (map proc seq)
  35.     (if (null? seq)
  36.         '()
  37.         (cons (proc (car seq))
  38.               (map proc (cdr seq))
  39.         )
  40.     )
  41.   )
  42.  
  43.   (define (for-each proc seq)
  44.     (if (not (null? seq))
  45.         (begin
  46.           (proc (car seq))
  47.           (for-each proc (cdr seq))
  48.         )
  49.     )
  50.   )
  51.  
  52.   (define (make-point x y)
  53.     (cons x y)
  54.   )
  55.  
  56.   (define (point-x p)
  57.     (car p)
  58.   )
  59.  
  60.   (define (point-y p)
  61.     (cdr p)
  62.   )
  63.  
  64.   (define (point-list->double-array point-list)
  65.     (define (convert points array pos)
  66.       (if (not (null? points))
  67.           (begin
  68.             (aset array (* 2 pos) (point-x (car points)))
  69.             (aset array (+ 1 (* 2 pos)) (point-y (car points)))
  70.             (convert (cdr points) array (+ pos 1))
  71.           )
  72.       )
  73.     )
  74.  
  75.     (let* (
  76.           (how-many (length point-list))
  77.           (a (cons-array (* 2 how-many) 'double))
  78.           )
  79.       (convert point-list a 0)
  80.       a
  81.     )
  82.   )
  83.  
  84.   (define (make-arrow size
  85.                       offset)
  86.     (list (make-point offset offset)
  87.           (make-point (- size offset) (/ size 2))
  88.           (make-point offset (- size offset))
  89.     )
  90.   )
  91.  
  92.  
  93.   (define (rotate-points points size orientation)
  94.     (map (lambda (p)
  95.            (let ((px (point-x p))
  96.                  (py (point-y p)))
  97.              (cond ((= orientation 0) (make-point px py))           ; right
  98.                    ((= orientation 1) (make-point (- size px) py))  ; left
  99.                    ((= orientation 2) (make-point py (- size px)))  ; up
  100.                    ((= orientation 3) (make-point py px))           ; down
  101.              )
  102.            )
  103.          )
  104.          points
  105.     )
  106.   )
  107.  
  108.  
  109.   ; the main function
  110.  
  111.   (let* (
  112.         (img (car (gimp-image-new size size RGB)))
  113.         (grow-amount (/ size 12))
  114.         (blur-radius (/ size 3))
  115.         (offset (/ size 6))
  116.         (ruler-layer (car (gimp-layer-new img
  117.                                           size size RGBA-IMAGE
  118.                                           "Ruler" 100 NORMAL-MODE)))
  119.         (glow-layer (car (gimp-layer-new img
  120.                                          size size RGBA-IMAGE
  121.                                          "Alien Glow" 100 NORMAL-MODE)))
  122.         (bg-layer (car (gimp-layer-new img
  123.                                        size size RGB-IMAGE
  124.                                        "Background" 100 NORMAL-MODE)))
  125.         (big-arrow (point-list->double-array
  126.                     (rotate-points (make-arrow size offset)
  127.                                     size orientation)))
  128.         )
  129.  
  130.     (gimp-context-push)
  131.  
  132.     (gimp-image-undo-disable img)
  133.     ;(gimp-image-resize img (+ length height) (+ height height) 0 0)
  134.     (gimp-image-add-layer img bg-layer 1)
  135.     (gimp-image-add-layer img glow-layer -1)
  136.     (gimp-image-add-layer img ruler-layer -1)
  137.  
  138.     (gimp-edit-clear glow-layer)
  139.     (gimp-edit-clear ruler-layer)
  140.  
  141.     (gimp-free-select img 6 big-arrow CHANNEL-OP-REPLACE TRUE FALSE 0)
  142.  
  143.     (gimp-context-set-foreground '(103 103 103))
  144.     (gimp-context-set-background '(0 0 0))
  145.  
  146.     (gimp-edit-blend ruler-layer FG-BG-RGB-MODE NORMAL-MODE
  147.                      GRADIENT-SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE
  148.                      FALSE 0 0 TRUE
  149.                      0 0 size size)
  150.  
  151.     (gimp-selection-grow img grow-amount)
  152.     (gimp-context-set-foreground glow-color)
  153.     (gimp-edit-fill glow-layer FOREGROUND-FILL)
  154.  
  155.     (gimp-selection-none img)
  156.  
  157.  
  158.     (plug-in-gauss-rle RUN-NONINTERACTIVE img glow-layer blur-radius TRUE TRUE)
  159.  
  160.     (gimp-context-set-background bg-color)
  161.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  162.  
  163.     (if (= flatten TRUE)
  164.         (gimp-image-flatten img)
  165.     )
  166.     (gimp-image-undo-enable img)
  167.     (gimp-display-new img)
  168.  
  169.     (gimp-context-pop)
  170.   )
  171. )
  172.  
  173. (script-fu-register "script-fu-alien-glow-right-arrow"
  174.   _"_Arrow..."
  175.   _"Create an arrow graphic with an eerie glow for web pages"
  176.   "Adrian Likins"
  177.   "Adrian Likins"
  178.   "1997"
  179.   ""
  180.   SF-ADJUSTMENT _"Size"             '(32 5 150 1 10 0 1)
  181.   SF-OPTION     _"Orientation"      '(_"Right" _"Left" _"Up" _"Down")
  182.   SF-COLOR      _"Glow color"       '(63 252 0)
  183.   SF-COLOR      _"Background color" "black"
  184.   SF-TOGGLE     _"Flatten image"    TRUE
  185. )
  186.  
  187. (script-fu-menu-register "script-fu-alien-glow-right-arrow"
  188.                          "<Image>/File/Create/Web Page Themes/Alien Glow")
  189.